#!/home/joshua/.guix-profile/bin/guile \
-e main -s
!#

;; for read-line
(use-modules (ice-9 rdelim))

(define (string-to-bool string)
  (if (string=? string "y")
      #t
      #f))

(define* (ask-question question bool #:key
                       commentary)
  (display question)
  (display "\n")
  (let ([answer (read-line)])
    (if (eq? bool (string-to-bool answer))
        (display "Correct\n")
        (display "Wrong\n")))
  (display "\n")
  (when commentary
    (display commentary)
    (display "\n")))

(define (atom? arg)
  (not (list? arg)))

(define (main args)
  (ask-question "Is this an atom? atom\n" #t)
  (ask-question "Is this an atom? 1234" #t)
  (ask-question "Is this a list? (atom)" #t)
  (ask-question "Is this an atom? (1 2 3)" #f)
  (ask-question "Is this an list? ()" #t
                #:commentary "Yes.  This is a special list, called the empty list.")
  )
